package guoanmaker.operator.business.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import guoanmaker.operator.business.model.OperatorCompanyDevelopServer;
import guoanmaker.operator.business.model.OperatorEventDetails;
import guoanmaker.operator.business.model.OperatorHotBusiness;
import guoanmaker.operator.business.model.OperatorHotwords;
import guoanmaker.operator.business.model.OperatorOfficeSpace;
import guoanmaker.operator.business.model.OperatorPcActive;
import guoanmaker.operator.business.model.OperatorPcCompanyDevelop;
import guoanmaker.operator.business.model.OperatorRoundPhoto;
import guoanmaker.operator.business.model.OperatorServerClass;
import guoanmaker.operator.business.repository.OperatorCompanyDevelopServerRepository;
import guoanmaker.operator.business.repository.OperatorEventDetailsRepository;
import guoanmaker.operator.business.repository.OperatorHotBusinessRepository;
import guoanmaker.operator.business.repository.OperatorHotwordsRepository;
import guoanmaker.operator.business.repository.OperatorOfficeSpaceRepository;
import guoanmaker.operator.business.repository.OperatorPcActiveRepository;
import guoanmaker.operator.business.repository.OperatorPcCompanyDevelopRepository;
import guoanmaker.operator.business.repository.OperatorRoundPhotoRepository;
import guoanmaker.operator.business.repository.OperatorServerClassRepository;

@Service
public class OperatorGroundPcService implements OperatorGroundPcServiceInterface {
	@Autowired
	 private  OperatorRoundPhotoRepository operatorRoundPhotoRepository;
	@Autowired
	private OperatorHotBusinessRepository operatorHotBusinessRepository;
	@Autowired
	private  OperatorHotwordsRepository operatorHotwordsRepository;
	@Autowired
	private OperatorPcActiveRepository operatorPcActiveRepository;
	@Autowired
	private OperatorEventDetailsRepository operatorEventDetailsRepository;
	@Autowired
	private OperatorCompanyDevelopServerRepository operatorCompanyDevelopServerRepository;
	@Autowired
	private OperatorPcCompanyDevelopRepository operatorPcCompanyDevelopRepository;
	@Autowired
	private OperatorServerClassRepository operatorServerClassRepository;
	@Autowired
	private OperatorOfficeSpaceRepository oeratorOfficeSpaceRepository;
	@Override
	public Map selectgroundPc(String cityCode) {
		Map<String, Object> reMap = new HashMap<>();
		List<OperatorRoundPhoto>  rpspps=operatorRoundPhotoRepository.findBycityCode(cityCode);
		reMap.put("rpspps", rpspps);
		List<OperatorHotBusiness> ops=operatorHotBusinessRepository.getOperatorHotBusiness(cityCode);
		reMap.put("ops", ops);
		OperatorHotwords hot=operatorHotwordsRepository.findPcByCityCodeOne(cityCode);
		 List<OperatorHotwords> hots= operatorHotwordsRepository.findPcByCityCodetwo(cityCode);
		 reMap.put("hot", hot);
		 reMap.put("hots", hots);
		 List<OperatorPcActive> ocactives=operatorPcActiveRepository.getOperatorPcActive(cityCode);
			if(ocactives.size()>0){
				for(OperatorPcActive ocs:ocactives){
					OperatorEventDetails operatorEventDetails=operatorEventDetailsRepository.getSelectEventByid(ocs.getActiveId());
					if(null==operatorEventDetails){
						ocs.setActiveId("");
					}
				}
			}
			reMap.put("ocactives", ocactives);
			
			List<OperatorPcCompanyDevelop> opds=operatorPcCompanyDevelopRepository.getOperatorPcCompanyDevelops(cityCode);
			for(OperatorPcCompanyDevelop opd:opds){
				OperatorCompanyDevelopServer[] depservers=operatorCompanyDevelopServerRepository.getOperatorCompanyDevelopServers(opd.getId());
				opd.setOperatorCompanyDevelopServers(depservers);
			}
			List<OperatorServerClass> serverTwos=operatorServerClassRepository.selectByTwoServerclass();
			List<OperatorServerClass> serverThrees=operatorServerClassRepository.selectByThreeServerclass();
			reMap.put("opds", opds);
			reMap.put("serverTwos", serverTwos);
			reMap.put("serverThrees", serverThrees);
			List<OperatorOfficeSpace> opspace =oeratorOfficeSpaceRepository.getOperatorOfficeSpace(cityCode);
			reMap.put("opspace", opspace);
		 
		return reMap;
	}

}
